<?php

/**
 * 定时器
 * Class Timer
 */
class Timer
{
    public function test() {
        $path =  '../runtime/log/timer.log';
        swoole_timer_tick(1000, function () use ($path) {
            file_put_contents($path,date('Y-m-d H:i:s') . PHP_EOL,FILE_APPEND);
        });
        // 阻塞程序
        \Swoole\Event::wait();
    }
}

// nohup /usr/local/php/bin/php /data/www/easy-php/server/Timer.php >/dev/null 2>&1 &
$timer = new Timer();
$timer->test();